import { Column, Entity, Generated, PrimaryGeneratedColumn } from 'typeorm';

export enum DeliveryStatus {
  // 待配送
  PENDING = 'pending',
  // 配送中
  HANDING = 'handing',
  // 已送达
  COMPLETED = 'completed',
  // 已取消
  CANCELED = 'canceled',
}

@Entity('tb_delivery', {
  comment: '配送单表',
})
export class Delivery {
  @PrimaryGeneratedColumn('increment', { comment: '自增主键', unsigned: true })
  id: number;

  @Column({ comment: '配送编号', unique: true })
  @Generated('uuid')
  no: string;

  @Column({ comment: '配送人员' })
  postmanId: number;

  @Column({ comment: '发货地址' })
  origin: JSON;

  @Column({ comment: '收货地址' })
  destination: string;

  @Column({ comment: '配送清单' })
  records: JSON;

  @Column({ comment: '核验代码' })
  code: string;

  @Column({ comment: '配送状态', default: DeliveryStatus.PENDING })
  status: DeliveryStatus;
}
